<?php
session_start();
function conectarse(){
	$db_host="127.0.0.1";
	$db_nombre="iusm";
	$db_user="iusm";
	$db_pass="iusm";
	$link=mysql_connect($db_host, $db_user, $db_pass) or die ("Error conectando a la base de datos.");
	mysql_select_db($db_nombre ,$link) or die("Error seleccionando la base de datos."); 
	return $link;
}

function location($url="#"){echo "<script> document.location.href=\"$url\"; </script>";}

$user = $_POST["user"];
$pass = $_POST["pass"];

$link = conectarse();
$query="SELECT * FROM usuarios WHERE user = '$user' AND pass = '$pass';";
$result=mysql_query($query,$link);
$count=mysql_num_rows($result);
if($count==1){
$_SESSION["id_usuario"] = $user;
location("lista.php");
}
else echo $user." --- ".$pass;
?>